import React from 'react'
import { useDispatch, useSelector } from 'react-redux'
import { SwipeCell, Toast, Button, Cell } from 'react-vant'
import { ListItem } from '../../store/reducer/userHistory'
type Props = {}

const Index = (props: Props) => {
	const userHistory = useSelector((state: any) => state.userHistory.list as ListItem[])
	const dispatch = useDispatch()
	return (
		<div>
			{
				userHistory.map((v, i) => {
					return (
						<SwipeCell
							key={i}
							rightAction={
								<Button style={{ height: '100%' }} square type="danger" onClick={() => dispatch({  type: 'SUB_USER_HISTORY', payload: v}) }>
									删除
								</Button>
							}
						>
							<Cell title={ v.title } value={ v.desc } />
						</SwipeCell>
					)
				})
			}
		</div>
	)
}

export default Index